#!/bin/sh

if [ $# -eq 0 ] || [ -z "$1" ]; then
    echo "错误: 请提供目标平台参数 (hi3519 或 hi3516cv610)"
    exit 1
fi

make distclean
CROSS_COMPILE=$1
OUTPUT_DIR=$2
OUTPUT_OBJ_PATH=$OUTPUT_DIR/obj/third_party/busybox
BASE_OUTPUT_PATH=$PWD/output
OUTPUT_PATH=$BASE_OUTPUT_PATH/$DEV

# if [ -d "$OUTPUT_PATH" ]; then
#     rm -rf $OUTPUT_PATH
# fi

mkdir -p $OUTPUT_OBJ_PATH
make ph_defconfig O=$OUTPUT_OBJ_PATH
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE O=$OUTPUT_OBJ_PATH -j8

cp $OUTPUT_OBJ_PATH/busybox $OUTPUT_DIR/usr/bin

